<?php
class valid extends AppModel{
	var $useTable = false; // không sử dụng table valid ðồng nghĩa là không sử dụng database
	var $validate = array(); // name space mặc định khi sử dụng datavalidation
	function valid_01(){
		$this->validate = array(
			"username"=>array(
				"rule1"=>array(
					"rule"=>"notEmpty",
					"message"=>"username can not empty",
				),
				"rule2" => array(
					"rule" => array('minLength', 4),
					"message" => "Usernames must be at least 4 characters long",
				),
				"rule3" => array(
					"rule" => array('maxLength', 10),
					"message" => "Usernames must be no larger than 10 characters long",
				),
			),
			"email" => array(
				"rule1" => array(
					"rule" => "notEmpty",
					"message" => "Please enter email !",
				),
				"rule2" => array(
					"rule" => "email",
					"message" => "Email not avaliable !",
				),
			),
			"website" => array(
				"rule1" => array(
					"rule" => "notEmpty",
					"message" => "Please enter website !",
				),
				"rule2" => array(
					"rule" => "url",
					"message" => "website is not avaliable",
				),
			),
			"customer" => array(
					"rule1" => array(
							"rule" => "notEmpty",
							"message" => "Please enter website !",
					),
					"rule2" => array(
							"rule" => "customer",
							"message" => "website is not avaliable",
					),
			),
		);
		if($this->validates($this->validate)) return TRUE;
		else return FALSE;

	}
	function customer(){
		if($this->data['Valid']['customer'] == "dat") return true;
		else return false;
	}

}